package servlet;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

@WebServlet(value = "/test",loadOnStartup = 1)
public class ServletTest extends HttpServlet{
    private static int counter = 0;

    public ServletTest(){
        super();
        System.out.println("ServletTest: " + ++counter + " instances");
    }

    @Override
    public void init(ServletConfig config)throws ServletException {
        super.init(config);
        System.out.println("ServletTest: invoke init() " + new Date().toString());
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("ServletTest: invoke doGet() " + new Date().toString());
    }
}
